@extends('front.layouts.app')

@section('content') 
    @include('front.layouts.adver')
        <section>
            <div class="container">
                <div class="row">
                    @include('front.category.category')
                    <div class="col-sm-9 padding-right">
                        <div class="features_items"> 
                            @if(count($products)>0)
                            <div id="boxp"> 
                                <div class="row"> 
                                       @foreach($products as $p)
                                              <div class="col-sm-4" id="item">
                                <div class="product-image-wrapper" >
                                    <div class="single-products">
                                        <div class="productinfo text-center">
                                            <img alt="" height="220" src="{{asset('productpics/').'/'.$p->pro_img}}"/>
                                            <h2 attr-price="{{$p->pro_prices}}" id="price">
                                                ￥{{$p->pro_prices}}
                                            </h2>
                                            <p>
                                                {{$p->pro_name}}
                                            </p>
                                            <a class="btn btn-default add-to-cart" href="{{route('add-cart',$p->pro_code)}}">
                                                <i class="fa fa-shopping-cart">
                                                </i>
                                                加入购物车
                                            </a>
                                            <a class="btn btn-default add-to-cart" href="{{route('details',$p->pro_code)}}" style="margin-left: 2px;">
                                                <i class="fa fa-eye">
                                                </i>
                                                查看详情
                                            </a>
                                        </div> 
                                    </div>
                                    {{-- {{$product->wishlist}} --}}
                                    
                                    {{-- <div class="choose">
                                        <ul class="nav nav-pills nav-justified">
                                         
                                         @guest
                                         @else
                                         @if($product->wishlist->isNotEmpty())  
                                             @foreach ($product->wishlist as $wishlist)
                                                 @if($wishlist->user_id == auth()->id())
                                                  <li>
                                                    <a href="{{route('wishlist.destroy',$wishlist->id)}}">
                                                        <i class="fa fa-times">
                                                        </i>
                                                        在愿望单删除
                                                    </a>
                                                </li>  
                                                 @endif
                                            @endforeach                     
                                         @else

                                          <li>
                                                <a  href="javascript:viod(0);" 
                                                    onclick="event.preventDefault();document.getElementById('logout-form').submit();" >
                                                    <i class="fa fa-plus">
                                                    </i>
                                                    添加到愿望单
                                                </a>
                                                <form action="{{route('add-wishlist')}}" id="logout-form" method="POST" style="display: none;">
                                                    <input type="hidden" name="product_id" title="code!" value="{{$product->pro_code}}">
                                                    {{ csrf_field() }}
                                                </form>
                                            </li>

                                        @endif
                                         @endguest
                                           
                                        </ul>
                                    </div> --}}
                                    
                                </div>
                            </div>
                                       @endforeach
                                     
                                </div> 
                            
                        </div>
                        <!--features_items-->
                        {{$products->links()}}
                        @else
                        <h1>
                            暂时没有此类商品
                        </h1>
                        @endif
                    </div>
                </div>
            </div>
        </section>
       @include('front.layouts.footer')
        <!--/Footer-->

          <script>
          $( function() {
            $( "#slider-range2" ).slider({
              range: true,
              min: 0,
              max: 20000,
              values: [ 75, 300 ],
              slide: function( event, ui ) { 
                $( "#start").text("最低:"+ui.values[0]);
                $( "#end" ).text("最高:"+ui.values[1]);

              }
            });

              $( "#start" ).text("最低:"+$( "#slider-range2" ).slider( "values", 0 ));
              $( "#end" ).text("最高:"+$( "#slider-range2" ).slider( "values", 1 ));

              $("#price-range").click(function(){

                $.get('{{ route('categoris') }}',{
                    'start':$( "#slider-range2" ).slider( "values", 0 ),
                    'end':$( "#slider-range2" ).slider( "values", 1 )
                },function(res){
                    
                    $("#boxp").html(res);
                     

              })
              })

          } );

          </script>     
@endsection